<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css" />
    <style>
        .layui-input-block{
            width: 200px;
        }
    </style>
</head>
<body>
<form class="layui-form" id="user-add"  action="" lay-filter="add">
    <div class="layui-form-item">
        <label class="layui-form-label">身份：</label>
            <div class="layui-input-block">
                <select name="rid" id="rid" lay-verify="required">
                    <option value="1">超级管理员</option>
                    <option value="2">管理员</option>
                    <option value="3">后勤人员</option>
                </select>
            </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">账号：</label>
        <div class="layui-input-inline layui-col-md1">
            <input type="text" name="uusername" id="uusername"  required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码：</label>
        <div class="layui-input-inline layui-col-md2">
            <input type="text" name="upassword" id="upassword"  required  lay-verify="required" placeholder="请输入账号" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名：</label>
        <div class="layui-input-inline layui-col-md3">
            <input type="text" name="uname" id="uname"  required  lay-verify="required" placeholder="请输入姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">年龄：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="uage" id="uage"  required  lay-verify="required" placeholder="请输入年龄" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话：</label>
        <div class="layui-input-inline layui-col-md5">
            <input type="tel" name="utel" id="utel" lay-verify="required" placeholder="请输入电话" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-inline layui-col-md6">
            <input type="tel" name="ustatus" id="ustatus" lay-verify="required" placeholder="请输入状态" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>

<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>

    //Demo
    layui.use(['form','laydate'], function(){
        var form = layui.form;
        var laydate = layui.laydate;
        var $=layui.$;
        //监听提交
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("add");
            $.ajax({
                url:'/UserServlet?method=insert',
                type:"post",
                dataType:"json",
                data:data1,
                success:function (da) {
                    if (da.code == 0) {
                        layer.alert("添加成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                            layer.msg("添加成功！");
                        })
                    } else {
                        layer.msg("添加失败！");
                    }
                }
            });
            return false;
        });

    });
</script>
</html>